<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="tKpJiageList" sortName="sortmy" checkbox="true" pagination="true" fitColumns="false" title="销售价格" actionUrl="tKpJiageController.do?datagrid" idField="id" fit="true" queryMode="group">

   <%--<t:dgCol title="客户编码"  field="cusCode"  query="true"  queryMode="single"  dictionary="pop_kp_cus,cusCode,cusName,cus_code,cus_name"  popup="true"  width="120"></t:dgCol>--%>
   <t:dgCol title="客户名称"  field="cusName"  query="true"  queryMode="single" dictionary="t_kp_cus,cus_name,cus_name" width="60"></t:dgCol>
   <%--<t:dgCol title="工地编码"  field="gdCode"  query="true"  queryMode="single"  dictionary="pop_kp_gongdi,gdCode,gdName,gd_code,gd_name"  popup="true"  width="120"></t:dgCol>--%>
   <t:dgCol title="承建单位"  field="gdName"  query="true"  queryMode="single"  width="220"></t:dgCol>
   <%--<t:dgCol title="产品编码"  field="cpCode"  query="true"  queryMode="single"  dictionary="pop_kp_chanpin,cpCode,cpName,cp_code,cp_name"  popup="true"  width="120"></t:dgCol>--%>
   <t:dgCol title="产品名称"  field="cpName"  query="true"  queryMode="single"  width="60"></t:dgCol>
   <%--<t:dgCol title="规格"   field="by1"  queryMode="single"  width="80"></t:dgCol>--%>
   <t:dgCol title="规格"     field="by2"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="等级"   hidden="true" field="by3"  queryMode="single"  width="70"></t:dgCol>
   <t:dgCol title="单位"   hidden="true" field="by4"  queryMode="single"  width="70"></t:dgCol>
   <t:dgCol title="开票价格"  field="cpJiage"  queryMode="single"  width="60"></t:dgCol>
   <t:dgCol title="待审批价格"  field="cpDshenjia" extendParams="editor:'text'" queryMode="single"  width="60"></t:dgCol>
   <t:dgCol title="出厂价"  field="chuchangfei" extendParams="editor:'text'" queryMode="single"  width="60"></t:dgCol>
   <t:dgCol title="运输费"  field="yunshufei" extendParams="editor:'text'" queryMode="single"  width="60"></t:dgCol>

   <t:dgCol title="备注"  field="jgRemark"  queryMode="single"  width="60"></t:dgCol>
   <%--<t:dgCol title="申请备注"  field="sqRemark"  queryMode="single"  width="120"></t:dgCol>--%>
   <%--<t:dgCol title="审批备注"  field="spRemark"  queryMode="single"  width="120"></t:dgCol>--%>


   <t:dgCol title="备用5"  hidden="true"  field="by5"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="排序"  field="sortmy"  hidden="true"  queryMode="single"  width="120"></t:dgCol>

   <t:dgCol title="操作" field="opt" width="60"></t:dgCol>
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建人名称"  field="createName"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建人"  field="createBy"    queryMode="single"  width="60"></t:dgCol>
   <t:dgCol title="创建日期"  field="createDate"  hidden="true" formatter="yyyy-MM-dd"    queryMode="single"  width="80"></t:dgCol>
   <t:dgCol title="更新人名称"  field="updateName"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新人登录名称"  field="updateBy"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新日期"  field="updateDate"    formatter="yyyy-MM-dd"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="所属部门"  field="sysOrgCode"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="所属公司"  field="sysCompanyCode"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="流程状态"  field="bpmStatus"  queryMode="single"  dictionary="bpm_status"  width="60"></t:dgCol>
   <t:dgDelOpt operationCode="jgdel" title="删除" url="tKpJiageController.do?doDel&id={id}" urlclass="ace_button" exp="bpmStatus#eq#1" urlfont="fa-trash-o"/>
   <t:dgToolBar operationCode="jgcreate" title="价格申请" icon="icon-add" url="tKpJiageController.do?goAdd" funname="add" width="780" height="400"></t:dgToolBar>
   <t:dgToolBar operationCode="jgedit" title="编辑" icon="icon-edit" url="tKpJiageController.do?goUpdate" funname="update" width="780" height="400"></t:dgToolBar>


   <t:dgToolBar  operationCode="jgebatedit" title="开始批量编辑" icon="icon-edit"  funname="editRow"></t:dgToolBar>
   <t:dgToolBar  operationCode="jgebatsave" title="批量保存" icon="icon-save" url="tKpJiageController.do?saveRows" funname="saveData"></t:dgToolBar>
   <t:dgToolBar  operationCode="jgebateditqx"  title="取消批量编辑" icon="icon-undo" funname="reject"></t:dgToolBar>
   <%--<t:dgToolBar title="批量删除"  icon="icon-remove" url="tKpJiageController.do?doBatchDel" funname="deleteALLSelect"></t:dgToolBar>--%>
   <t:dgToolBar title="查看" icon="icon-search" url="tKpJiageController.do?goUpdate" funname="detail" width="780" height="400"></t:dgToolBar>
   <%--<t:dgToolBar title="导入" icon="icon-put" funname="ImportXls"></t:dgToolBar>--%>
   <t:dgToolBar title="导出" icon="icon-putout" funname="ExportXls"></t:dgToolBar>
   <%--<t:dgToolBar title="模板下载" icon="icon-putout" funname="ExportXlsByT"></t:dgToolBar>--%>
  </t:datagrid>
  </div>
 </div>
 <script src = "webpage/com/yserp/kpmd/tKpJiageList.js"></script>		
 <script type="text/javascript">
 $(document).ready(function(){
 });


 //添加行
 function addRow(title,addurl,gname){
     $('#'+gname).datagrid('appendRow',{});
     var editIndex = $('#'+gname).datagrid('getRows').length-1;
     $('#'+gname).datagrid('selectRow', editIndex)
         .datagrid('beginEdit', editIndex);
 }
 //保存数据
 function saveData(title,addurl,gname){
     if(!endEdit(gname))
         return false;
     var rows=$('#'+gname).datagrid("getChanges","inserted");
     var uprows=$('#'+gname).datagrid("getChanges","updated");
     rows=rows.concat(uprows);
     if(rows.length<=0){
         tip("没有需要保存的数据！")
         return false;
     }
     var result={};
     for(var i=0;i<rows.length;i++){
         for(var d in rows[i]){
             result["demos["+i+"]."+d]=rows[i][d];
         }
     }
     $.ajax({
         url:"<%=basePath%>/"+addurl,
         type:"post",
         data:result,
         dataType:"json",
         success:function(data){
             tip(data.msg);
             if(data.success){
                 $('#tKpJiageList').datagrid('reload',{});
             }
         }
     })
 }
 //结束编辑
 function endEdit(gname){
     var  editIndex = $('#'+gname).datagrid('getRows').length-1;
     for(var i=0;i<=editIndex;i++){
         if($('#'+gname).datagrid('validateRow', i)){
             $('#'+gname).datagrid('endEdit', i);
         }else{

             tip("请选择必填项(带有红色三角形状的字段)!");

             return false;
         }
     }
     return true;
 }
 //编辑行
 function editRow(title,addurl,gname){
     var rows=$('#'+gname).datagrid("getChecked");
     if(rows.length==0){
         tip("请选择条目");
         return false;
     }
     for(var i=0;i<rows.length;i++){
         var index= $('#'+gname).datagrid('getRowIndex', rows[i]);
         $('#'+gname).datagrid('beginEdit', index);
     }
 }

 //取消编辑
 function reject(title,addurl,gname){
     $('#'+gname).datagrid('clearChecked');
     $('#'+gname).datagrid('rejectChanges');


 }
 
//导入
function ImportXls() {
	openuploadwin('Excel导入', 'tKpJiageController.do?upload', "tKpJiageList");
}

//导出
function ExportXls() {
	JeecgExcelExport("tKpJiageController.do?exportXls","tKpJiageList");
}

//模板下载
function ExportXlsByT() {
	JeecgExcelExport("tKpJiageController.do?exportXlsByT","tKpJiageList");
}

 </script>